<?php


/**
* CakePHP Routines Plugin
* http://cake-routines-plugin.googlecode.com
*
* @package routines
* @subpackage routines.controllers.components
* @author Ivan Chistyakov <zetruger@gmail.com>
* @version $Id: utils.php 175 2010-10-26 08:00:09Z zetruger@gmail.com $
* @link $HeadURL: http://cake-routines-plugin.googlecode.com/svn/trunk/controllers/components/utils.php $
* @license MIT License (http://opensource.org/licenses/mit-license.php)
*/


class UtilsComponent extends Object {

var $components = array('RequestHandler');

var $_controller = NULL;

function initialize(&$Controller, $settings = array()) {
	$this->_controller = $Controller;
}

function disableAll() {
	$ctrl = &$this->_controller;
	Configure::write('debug', 0);
	$ctrl->disableCache();
	$ctrl->autoRender = FALSE;
	@ob_clean();
}

function setLanguage($lang = NULL) {
	$ctrl = &$this->_controller;
	if (is_null($lang) && isset($ctrl->params['lang'])) {
		$lang = $ctrl->params['lang'];
	}
	$l10n = new L10n();
	$l10n->get($lang);
	if (!in_array($l10n->locale, (array)Configure::read('Config.languages')) && defined('DEFAULT_LANGUAGE')) {
		$l10n->get(DEFAULT_LANGUAGE);
	}
	Configure::write('Config.language', $l10n->locale);
	$ctrl->set(array('locale' => $l10n->locale, 'lang' => $l10n->lang, 'l10n' => $l10n->catalog($l10n->lang)));
}

}


?>